<style scoped>
  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }
  .rj-cell.max span{
    font-size: 16px;
    padding-right: 20px;
  }
  .rj-cell label {
    color: #333;
    font-size: 14px;
    width: 44%;
    display: inline-block;
    padding: 5px 3%;
    text-align: right;
  }
  .rj-cell span {
    font-size: 14px;
    color: #333;
    display: inline-block;
    width: 50%;
  }
  .rj-cell.note label{
    float: left;
  }
  .rj-cell.note span{
    width: 80%;
    display: inline-block;
  }
  .weui-cell {
    background: #fff;
  }
  #acts span {
    font-size: 14px;
  }
  .weui-label{
    /*width: 130px;*/
    text-align: left;
  }

  .weui-select {
    height: auto;
    line-height: normal;
  }
  *{
    list-style:none;
  }
  /*body{*/

  /*}*/
  .weui-cell_select {
    padding: 10px 15px;
  }
  .weui-cells__title {
    text-align: left;
  }
  .hide {
    display: none;
  }
  #acts {
    font-size: 0;
  }
  #acts span {
    font-size: 14px;
  }
  input.time {
    border: none;
    font-size: 16px;
    padding-left: 10px;
  }
</style>
<template>
  <div class="oitem">
    <div class="weui-cells__title">货品明细{{index + 1}}</div>
    <input type="hidden" :name="'items[' + index + '].applyitemid'" :value="item.guid" />
    <input type="hidden" :name="'items[' + index + '].stockunit'" :value="item.stockunit" />
    <input type="hidden" :name="'items[' + index + '].stockunitid'" :value="item.stockunitid" />
    <div class="weui-cell fir">
      <div class="weui-cell__hd"><label class="weui-label">类型</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input" type="text" readonly :value="item.type == 2 ? '成品入库' : '不合格品入库'" />
      </div>
    </div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label">产品</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input product" readonly type="text" :value="item.product" name="" />
        <input class="weui-input" type="hidden" :value="item.productid" :name="'items[' + index + '].productguid'" />
      </div>
    </div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label">规格</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input specif" readonly type="text" :value="item.spename" name="" />
        <input class="weui-input" type="hidden" :value="item.specguid" :name="'items[' + index + '].spguid'" />
      </div>
    </div>
<!--    <div class="weui-cell weui-cell_select" v-if="type == 2">-->
<!--      <div class="weui-cell__hd"><label class="weui-label">规格</label></div>-->
<!--      <div class="weui-cell__bd">-->
<!--        <input type="hidden" :name="'items[' + index + '].spguid'" :value="spec.guid">-->
<!--        <input type="hidden" :name="'items[' + index + '].spename'" :value="spec.name">-->
<!--        <select class="weui-select specif" v-model="spec">-->
<!--          <option v-for="(spec, index) in specifications" :key="spec.guid" :value="spec">{{spec.name}}</option>-->
<!--        </select>-->
<!--      </div>-->
<!--    </div>-->
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label">数量{{item.stockunit ? `(${item.stockunit})` : ''}}</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input weight" type="number" :name="'items[' + index + '].weight'" />
      </div>
    </div>
    <div class="weui-cell weui-cell_select">
      <div class="weui-cell__hd"><label class="weui-label">库间</label></div>
      <div class="weui-cell__bd">
        <select class="weui-select house" :name="'items[' + index + '].shrguid'">
          <option v-for="(item, index) in houses" :key="item.guid" :value="item.guid">{{item.name}}</option>
        </select>
      </div>
    </div>
  </div>

</template>

<script>
export default {
  name: 'FeedStoreRmItem',
  data () {
    return {
      specifications: [],
      spec: {},
      houses: []
    }
  },
  props: [
    'item',
    'index',
    'productid',
    'srguid'
  ],
  watch: {
    'productid': function (val) {
      this.getSpecif(val);
    },
    'item.type': function (val) {
      this.getStrHouse(val);
    },
  },
  mounted() {
    this.$nextTick(function () {
      this.getStrHouse(this.item.type);
      // this.getSpecif(this.productid);
    })
  },
  methods: {
    getStrHouse: function(type) {
      this.axios({
        method: 'get',
        url: '/produce/StoreHouse!getHousesByType.action',
        params: {srguid: this.srguid, type: type}
      }).then((response) => {
        if (response.data.msg == 'success') {
          this.houses = response.data.houses;
        } else if (response != undefined && response.data != undefined && response.data.msg == 'sessionTimeOut') {
          //不不设置提示
        } else {
          this.toastError("系统错误");
        }

      })
    },
    getSpecif: function(productid) {
      this.axios({
        method: 'get',
        url: '/produce/Whinapply!getSpeByproduct.action',
        params: {productid: productid, type: 3, stats: '1,4'}
      }).then((response) => {
        if (response.data.msg == 'success') {
          let data = response.data;
          this.specifications = data.specifications;
        } else {
          this.toastError("系统错误");
        }
      })
    }
  }
}
</script>
